<template>
	<view class="seed-page page">
		<view class="category">
			<view class="first-category-block category-block">
				<view :key="item.id" v-for="(item,index) in list" :class="menuActive==item.id?'active':''"
					@click="changeMenuActive(item)" class="menu-item">{{item.name}}</view>
			</view>
			<view class="second-category-block category-block">
				<view class="name">豆类</view>
				<view class="info-list" v-for="item in childList" :key="item.id"
					@click="navigate('/page_pack/seed/seed_detail?id='+item.id)">
					<image :src="item.coverImage" mode="aspectFill" class="img"></image>
					<view class="info-item">
						<view class="info-name">{{item.name}}</view>
						<view class="describe">{{item.describe}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuActive: 1,
				list: [{
						id: 1,
						name: '全部'
					},
					{
						id: 2,
						name: '豆类'
					},
					{
						id: 3,
						name: '瓜类'
					},
					{
						id: 4,
						name: '茄果'
					},
					{
						id: 5,
						name: '芹菜'
					}
				],
				childList: [{
						id: 1,
						coverImage: '',
						name: '红花白荚架豆',
						describe: '早熟，播种至采收嫩荚55天，采收期30天左右。'
					},
					{
						id: 2,
						coverImage: '',
						name: '红花白荚架豆',
						describe: '早熟，播种至采收嫩荚55天，采收期30天左右。'
					}
				]
			}
		},
		methods: {
			changeMenuActive(menu) {
				this.menuActive = menu.id
			},
		},
		onLoad() {

		}
	}
</script>

<style lang="scss" scoped>
	.seed-page {
		width: 100%;
		padding: 10rpx 30rpx;
		background-color: #fff;

		.category {
			width: 100%;
			display: flex;
			flex-direction: row;

			.category-block {
				height: calc(100vh - var(--window-bottom) - var(--window-top) - 160rpx);
				overflow-y: scroll;
				display: flex;
				flex-direction: column;
				align-items: center;
			}

			.first-category-block {
				width: 180rpx;
				margin-right: 20rpx;

				.menu-item {
					display: flex;
					padding: 0 30rpx;
					justify-content: center;
					align-items: center;
					width: 100%;
					font-size: 30rpx;
					margin: 20rpx 0;
					height: 120rpx;
				}

				.menu-item.active {
					background-color: #F6F6F6;
					border-radius: 16rpx;
				}
			}

			.second-category-block {
				width: calc(100% - 200rpx);
				margin-top: 20rpx;

				.name {
					width: 100%;
					font-weight: bold;
					display: flex;
					justify-content: flex-start;
					margin-bottom: 30rpx;
				}

				.info-list {
					margin-bottom: 30rpx;
					display: flex;
					align-items: center;

					.img {
						width: 160rpx;
						height: 160rpx;
						border-radius: 20rpx;
						background-color: #F6F6F6;
						margin-right: 10rpx;
					}

					.info-item {
						width: calc(100% - 170rpx);

						.info-name {
							margin-bottom: 20rpx;
						}

						.describe {
							font-size: 26rpx;
							color: #999;
							line-height: 40rpx;
							display: -webkit-box;
							overflow: hidden;
							text-overflow: ellipsis;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2; //想显示多少行
						}
					}
				}
			}
		}
	}
</style>